package com.bosssoft.springboot.demo1.util;


import com.bosssoft.springboot.demo1.util.result.Response;
import com.bosssoft.springboot.demo1.util.result.ResultCode;

import java.util.ArrayList;
import java.util.List;

/**
 * @description 响应封装工具类
 * @date 2020/6/5
 * @author ChenTong
 */
public class ResponseUtil {
    private ResponseUtil(){}

    public static Response success(Object data) {
        return new Response<>(ResultCode.SUCCESS, data);
    }

    //    创建新的提示返回信息
    public static Response warn(ResultCode resultCode, String msg) {
        Response<Object> response = new Response<>(resultCode);
        response.setMsg(msg);
        return response;
    }

    //    使用已有的返回信息
    public static Response warn(ResultCode resultCode) {
        List<Object> objects = new ArrayList<>();
        return new Response<>(resultCode,objects);
    }
}
